package com.example.demo.controller;

import com.example.demo.core.Result;
import com.example.demo.entity.District;
import com.example.demo.service.DistrictService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 地理位置区/县控制器
 *
 * @author 叮当猫的百宝箱
 * @since 1.0
 */
@Tag(name = "地理位置区/县信息", description = "地理位置区/县信息")
@RestController
@RequestMapping("/geo")
@RequiredArgsConstructor
public class DistrictController {
    private final DistrictService districtService;

    /**
     * 根据市级编码获取辖区的区/县级行政辖区列表
     *
     * @param cityCode 市级辖区编码
     * @return API全局响应对象
     */
    @GetMapping("/city/{cityCode}/district")
    public Result<List<District>> getDistrictListByCityCode(@PathVariable("cityCode") String cityCode) {
        List<District> districtList = districtService.getByCityCode(cityCode);
        return Result.ok(districtList);
    }

}
